package homework.day01;

import java.util.Random;
import java.util.Scanner;

public class Test6 {
    public static void main(String[] args) {
        String code = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        Random random = new Random();
        String line = "";
        for(int i=0;i<4;i++) {
            int index = random.nextInt(code.length());
            char c = code.charAt(index);
            line = line + c;
        }
        System.out.println(line);

        System.out.println("请输入验证码:");
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();

        if(str.equalsIgnoreCase(line)){
            System.out.println("验证码正确");
        }else{
            System.out.println("验证码错误");
        }
    }
}
